#include "EQU.H"
#include "ETC.H"
#include "ACTION.H"



















void frameoutchk(sprite_status* pActwk) { /* Line 23, Address: 0x1000fe0 */
  short xposi;
  short scra_h;
  unsigned char index;

  xposi = pActwk->xposi.w.h; /* Line 28, Address: 0x1000ff8 */
  xposi &= -128; /* Line 29, Address: 0x1001008 */
  scra_h = scra_h_posit.w.h; /* Line 30, Address: 0x1001018 */
  scra_h -= 128; /* Line 31, Address: 0x1001028 */
  scra_h &= -128; /* Line 32, Address: 0x1001034 */
  xposi -= scra_h; /* Line 33, Address: 0x1001044 */
  if (xposi <= 640) /* Line 34, Address: 0x1001050 */
   {
    actionsub(pActwk); /* Line 36, Address: 0x1001064 */
  } /* Line 37, Address: 0x1001070 */
  else
  {
    index = pActwk->cdsts; /* Line 40, Address: 0x1001078 */
    if (index) flagwork[index] &= 127; /* Line 41, Address: 0x1001084 */
    frameout(pActwk); /* Line 42, Address: 0x10010a8 */
  }
} /* Line 44, Address: 0x10010b4 */








int sync() {
  if (int_flg) return -1; /* Line 54, Address: 0x10010d0 */
  return 0; /* Line 55, Address: 0x10010ec */
} /* Line 56, Address: 0x10010f0 */









void sinset(unsigned char kakudo, short* sin, short* cos) { /* Line 66, Address: 0x1001100 */
  unsigned short kakudo_w;
  unsigned short sintable[320] = /* Line 68, Address: 0x1001114 */
  {
      0,   6,  12,  18,  25,  31,  37,  43,
     49,  56,  62,  68,  74,  80,  86,  92,
     97, 103, 109, 115, 120, 126, 131, 136,
    142, 147, 152, 157, 162, 167, 171, 176,
    181, 185, 189, 193, 197, 201, 205, 209,
    212, 216, 219, 222, 225, 228, 231, 234,
    236, 238, 241, 243, 244, 246, 248, 249,
    251, 252, 253, 254, 254, 255, 255, 255,
    256, 255, 255, 255, 254, 254, 253, 252,
    251, 249, 248, 246, 244, 243, 241, 238,
    236, 234, 231, 228, 225, 222, 219, 216,
    212, 209, 205, 201, 197, 193, 189, 185,
    181, 176, 171, 167, 162, 157, 152, 147,
    142, 136, 131, 126, 120, 115, 109, 103,
     97,  92,  86,  80,  74,  68,  62,  56,
     49,  43,  37,  31,  25,  18,  12,   6,
        0, 65530, 65524, 65518, 65511, 65505, 65499, 65493,
    65487, 65480, 65474, 65468, 65462, 65456, 65450, 65444,
    65439, 65433, 65427, 65419, 65416, 65410, 65405, 65400,
    65394, 65389, 65384, 65379, 65374, 65369, 65365, 65360,
    65355, 65351, 65347, 65343, 65339, 65335, 65331, 65327,
    65324, 65320, 65317, 65314, 65311, 65308, 65305, 65302,
    65300, 65298, 65295, 65293, 65292, 65290, 65288, 65287,
    65285, 65284, 65283, 65282, 65282, 65281, 65281, 65281,
    65280, 65281, 65281, 65281, 65282, 65282, 65283, 65284,
    65285, 65287, 65288, 65290, 65292, 65293, 65295, 65298,
    65300, 65302, 65305, 65308, 65311, 65314, 65317, 65320,
    65324, 65327, 65331, 65335, 65339, 65343, 65347, 65351,
    65355, 65360, 65365, 65369, 65374, 65379, 65384, 65389,
    65394, 65400, 65405, 65410, 65416, 65419, 65427, 65433,
    65439, 65444, 65450, 65456, 65462, 65468, 65474, 65480,
    65487, 65493, 65499, 65505, 65511, 65518, 65524, 65530,
      0,   6,  12,  18,  25,  31,  37,  43,
     49,  56,  62,  68,  74,  80,  86,  92,
     97, 103, 109, 115, 120, 126, 131, 136,
    142, 147, 152, 157, 162, 167, 171, 176,
    181, 185, 189, 193, 197, 201, 205, 209,
    212, 216, 219, 222, 225, 228, 231, 234,
    236, 238, 241, 243, 244, 246, 248, 249,
    251, 252, 253, 254, 254, 255, 255, 255
  };






  kakudo_w = (kakudo & 65535) + 64; /* Line 117, Address: 0x1001148 */
  *cos = sintable[kakudo_w]; /* Line 118, Address: 0x1001160 */
  *sin = sintable[kakudo_w - 64]; /* Line 119, Address: 0x1001178 */
} /* Line 120, Address: 0x1001194 */









short atan_sonic(short x, short y) { /* Line 130, Address: 0x10011b0 */
  int xl, yl;
  short ret;
  char atantbl[257] = /* Line 133, Address: 0x10011c8 */
  {
     0,  0,  0,  0,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,
     3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  4,  5,  5,  5,
     5,  5,  5,  6,  6,  6,  6,  6,  6,  6,  7,  7,  7,  7,  7,  7,
     8,  8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9, 10, 10, 10,
    10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12,
    12, 12, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14,
    15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 17, 17,
    17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19,
    19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21,
    21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23,
    23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24,
    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26,
    26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28,
    28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29,
    29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31,
    31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32,
    32
  };
  xl = x; /* Line 153, Address: 0x10011f4 */
  yl = y; /* Line 154, Address: 0x1001200 */
  if (xl | yl) /* Line 155, Address: 0x100120c */
  {
    if (xl < 0) xl = -xl; /* Line 157, Address: 0x1001218 */
    if (yl < 0) yl = -yl; /* Line 158, Address: 0x1001224 */
    if (yl < xl) /* Line 159, Address: 0x1001230 */
    {
      yl = (yl << 8) & -256; /* Line 161, Address: 0x100123c */
      yl /= xl; /* Line 162, Address: 0x1001248 */
      ret = atantbl[yl]; /* Line 163, Address: 0x100125c */
    } /* Line 164, Address: 0x1001274 */
    else
    {
      xl = (xl << 8) & -256; /* Line 167, Address: 0x100127c */
      xl /= yl; /* Line 168, Address: 0x1001288 */
      ret = 64 - (short)atantbl[xl]; /* Line 169, Address: 0x100129c */
    }
    if (x < 0) /* Line 171, Address: 0x10012cc */
    {
      ret *= -1; /* Line 173, Address: 0x10012e0 */
      ret += 128; /* Line 174, Address: 0x10012ec */
    }
    if (y < 0) /* Line 176, Address: 0x10012f8 */
    {
      ret *= -1; /* Line 178, Address: 0x100130c */
      ret += 256; /* Line 179, Address: 0x1001318 */
    }
    return ret; /* Line 181, Address: 0x1001324 */
  }
  return 64; /* Line 183, Address: 0x1001330 */
} /* Line 184, Address: 0x1001334 */
